<!--{template admin/header}-->

<script type="text/javascript">
function check_name_exists()
{
	var name = $("#name").val();
	
	if(name != ''){
		$.get('ajax.php?m=business&a=check_name', {'name':name, 'type':'business'}, function(json){
			if(json.status == 'OK'){
				$("#id").val(json.result.id);
				$("#name").val(json.result.name);
				$("#legal_person").val(json.result.legal_person);
				$("#number").val(json.result.number);

				$("#image").html('<img width="120" height="120" src="'+json.result.image+'"><br />');
				$("#address").val(json.result.address);
				$("#telephone").val(json.result.telephone);
				$("#latitude").val(json.result.latitude);

				$("#longitude").val(json.result.longitude);

				//alert('名称已存在');
			}else{
				alert(json.message);
			}
		},'json')
	}else{
		alert('请输入名称！');
	}
	
}
</script>

<form method="post" enctype="multipart/form-data" action="manage.php?m=business&a={$action}">
	<table cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
		<tr class="header">
			<td colspan="2">{$action_name}</td>
		</tr>
		<tr>
			<td width="20%" bgcolor="#F8F8F8">
				商家名称&nbsp;<span style="color:red;">*</span>:
			</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="10" type="hidden" id="id" name="id" value="{$info[id]}">
		  		<input size="50" type="text" id="name" name="name" value="{$info[name]}" maxlength="255">
		  		<!-- {if $info[id] == '' } -->
		  		&nbsp;&nbsp;<a href="#" onclick="javascript:check_name_exists();">检查名称</a>
		  		<!-- {/if} -->
		  	</td>
		</tr>
		<tr>
			<td width="20%" bgcolor="#F8F8F8">
				Logo&nbsp;<span style="color:red;">*</span>: <br />
				图片支持jpg/jpeg/gif/png（小于<span style="color:red;">2M</span>）
			</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<div id="image">
		  		<!-- {if $info[image]} -->
				<a href="{$info[image]}" target="_blank"><img width="120" height="120" src="{$info[image]}"></a><br />
				<!-- {/if} -->
				</div>
				<input type="file" id="normalUploadFile" name="image" />
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">企业法人 / 企业编号:&nbsp;<span style="color:red;">*</span></td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="10" type="text" id="legal_person" name="legal_person" value="{$info[legal_person]}" maxlength="20"> / 
		  		<input size="30" type="text" id="number" name="number" value="{$info[number]}" maxlength="100">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">经营范围:</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="60" type="text" name="business_scope" value="{$info[business_scope]}" maxlength="100">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">联系电话:&nbsp;<span style="color:red;">*</span></td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="60" type="text" id="telephone" name="telephone" value="{$info[telephone]}" maxlength="50">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">人均消费:</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="10" type="text" name="avg_cost" value="{$info[avg_cost]}" maxlength="10"> 元
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">特色菜推荐数:</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="10" type="text" name="special_count" value="{$info[special_count]}" maxlength="10">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">已审批？:</td>
			<td align="right" bgcolor="#FFFFFF">
				<!--{if $info[is_validate] }-->
				<input class="checkbox" type="checkbox" name="is_validate" checked="">
				<!--{else}-->
		  		<input class="checkbox" type="checkbox" name="is_validate">
		  		<!--{/if}-->
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">简介:</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<textarea cols="60" rows="5" name="desc">{$info[desc]}</textarea>
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">评分(服务/环境/价格):<br />范围(0-5)</td>
			<td align="right" bgcolor="#FFFFFF">
		  		{$info[service_score]}&nbsp;/&nbsp;
		  		{$info[env_score]}&nbsp;/&nbsp;
		  		{$info[price_score]}
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">地址:&nbsp;<span style="color:red;">*</span></td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="60" type="text" id="address" name="address" value="{$info[address]}" maxlength="255">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">纬度 / 经度:&nbsp;<span style="color:red;">*</span></td>
			<td align="right" bgcolor="#FFFFFF">
		  		<input size="20" type="text" id="latitude" name="latitude" value="{$info[latitude]}" maxlength="20">
		  		<input size="20" type="text" id="longitude" name="longitude" value="{$info[longitude]}" maxlength="20">
		  	</td>
		</tr>
		<tr>
			<td bgcolor="#F8F8F8">
				在地图上定位:<br />
				（拖动标记到您所在的位置）
				<div id="city_select"></div>
			</td>
			<td align="right" bgcolor="#FFFFFF">
		  		<div style="width:520px;height:340px;border:1px solid gray" id="map_container"></div>
		  	</td>
		</tr>
	</table>
	<br />
	<center><input type="submit" class="button" name="addsubmit" value="提 交"></center>
</form>

<script type="text/javascript" src="templates/default/js/travel_info.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<script type="text/javascript" src="templates/default/js/map.js"></script>

<script type="text/javascript">
$(document).ready(function(){
	{if $info[latitude]}
	lat = {$info[latitude]};
	lng = {$info[longitude]};
	{/if}

	initCitySelect("city_select");
	init_map("map_container");
});
</script>